#ifndef EEPROM_H
#define EEPROM_H
#include "LCD_DRIVER.h"

#define SPIBUSY()					SPI0CFG & 0x80
#define ODOMETER_PAGE				5 
#define GPS_MIN_PAGE				500
#define GPS_MAX_PAGE				4000 // we can store 84,000 gps_log structs!
#define DONT_CARE					0
#define LCD_PAGE					1
#define LCD_PAGE_SPLASH_OFFSET		0
#define LCD_PAGE_SPLASH_LENGTH		80
#define LCD_PAGE_BACKSLASH_OFFSET	(LCD_PAGE_SPLASH_OFFSET + 80)


#define BUFFER_1_TO_PAGE		0x83
#define WRITE_BUFFER_1			0x84
#define BUFFER_2_TO_PAGE		0x86
#define WRITE_BUFFER_2			0x87
#define CONTINUOUS_PAGE_READ	0x03
#define DIRECT_PAGE_READ		0xD2	
	

void spi_write(unsigned char* buf, unsigned short len);
void spi_read(unsigned char* buf, unsigned short len);
void init_eeprom();
void save_odometer();
void dump_gps();
void save_gps_log(unsigned char force_write);

typedef struct{
	unsigned char op_code;
	unsigned short byte_address_h	: 2;  //bit alignment seems backwards to me...
	unsigned short page_address		: 12;
	unsigned short dont_care		: 2;
	unsigned char byte_address_l	: 8;
		
} eeprom_ptr;


#endif
